'use strict';
const {
  unicodeLength,
  regular,
  unicodeCharAt,
  unicodeCodePointAt,
  Rectangle,
  Square
} = require('../src/main.js');

var assert = require('assert');
require('mocha-sinon');

describe('class', function () {
  afterEach(function () {});
  beforeEach(function () {
    this.sinon.spy(console, 'log');
  });

  it('should first', function (done) {
    assert.strictEqual(1, 1);
    done();
  });

  it('should class', function (done) {
    let rectangle = new Rectangle(5,10);
    rectangle.sayName();
    assert.strictEqual(console.log.callCount, 1);
    assert.strictEqual(console.log.args[0][0], 'Hi, I am a ');
    assert.strictEqual(console.log.args[0][1], 'Rectangle.');

    let square = new Square(5);
    console.log(square.__proto__ == Square.prototype)//new操作符
    console.log(Square.__proto__ == Rectangle)//extend操作符
    console.log(Rectangle.__proto__)//还是个函数
    square.sayName();
    done();

    function A(){
      console.log("s");
    }

    let a = new A();
    console.log(a.__proto__ == A.prototype);

    // new操作符
    // 1. 生成空对象
    // 2. 对象的__prototype__ = F.prototype
    // 4. this = xx;
    // 3. Object.call(this, params)
  });
});
